{% extends 'base.html' %}
{% load rbac %}
{% block css %}
{#    自定义自己的样式#}
    <style>
        tr.active {
            border-left:3px solid #fdc00f;
        }
        table {
            font-size: 12px;
        }
        .panel-body {
            font-size: 12px;
        }

    </style>
{% endblock %}

{% block content %}
    <div class="luffy-container">
        <div class="col-md-3">
            <!-- 一级菜单 panel-->
            <div class="panel panel-default">
                <div class="panel-heading">
                    <i class="fa fa-book" aria-hidden="true"></i> 一级菜单
                    <a href="{% memory_url request 'rbac:menu_add' %}" class="right btn btn-success btn-xs"
                       style="padding: 2px 8px;margin: -3px;">
                        <i class="fa fa-plus-circle" aria-hidden="true"></i>
                        新建
                    </a>
                </div>
                <table class="table">
                    <thead>
                        <tr>
                            <th>名称</th>
                            <th>图标</th>
                            <th>选项</th>
                        </tr>
                    </thead>
                    <tbody>
                    {% for menu in menus %}
                        <tr class="{% if menu.id|safe == menu_id %}active{% endif %}">
                            <td>
                                <a href="?mid={{ menu.id }}">{{ menu.title }}</a>
                            </td>
                            <td><i class="fa {{ menu.icon }}" aria-hidden="true"></i></td>
                            {#                     {% if request|has_permission:"customer_edit" or request|has_permission:"customer_del" %}#}
                            <td>
                                {#                            {% if request|has_permission:"customer_edit" %}#}
                                <a style="color:#333333;" href="{% memory_url request 'rbac:menu_edit' pk=menu.id %}">
                                    <i class="fa fa-edit" aria-hidden="true"></i>
                                </a>
                                {#                            {%endif%}#}
                                {#                            {% if request|has_permission:"customer_edit" %}#}
                                <a style="color:#d9534f;" href="{% memory_url request 'rbac:menu_del' pk=menu.id %}">
                                    <i class="fa fa-trash-o"></i>
                                </a>
                                {#                            {% endif %}#}
                            </td>
                            {#                     {% endif %}#}
                        </tr>
                    {% endfor %}

                    </tbody>
                </table>
            </div>
        </div>

        <!-- 二级菜单 panel-->
        <div class="col-md-4">
            <!--table panel  -->
            <div class="panel panel-default">
                <div class="panel-heading">
                    <i class="fa fa-gavel" aria-hidden="true"></i> 二级菜单
                    {% if menu_id %}
                        <a href="{% memory_url request 'rbac:second_menu_add' %}" class="right btn btn-success btn-xs"
                           style="padding: 2px 8px;margin: -3px;">
                            <i class="fa fa-plus-circle" aria-hidden="true"></i>
                            新建
                        </a>
                    {% endif %}
                </div>
                <table class="table">
                    <thead>
                        <tr>
                            <th>名称</th>
                            <th>CODE&URL</th>
                            <th>选项</th>
                        </tr>
                    </thead>
                    <tbody>
                    {% for row in second_menus %}
                        <tr class="{% if row.id|safe == second_menu_id %}active{% endif %}">
                            <td rowspan="2">
                                <a href="?mid={{ menu_id }}&sid={{ row.id }}">{{ row.title }}</a>
                            </td>
                            <td>{{ row.name }}</td>
                            {#                     {% if request|has_permission:"customer_edit" or request|has_permission:"customer_del" %}#}
                            <td>
                                {#                            {% if request|has_permission:"customer_edit" %}#}
                                <a style="color:#333333;" href="{% memory_url request 'rbac:second_menu_edit' pk=row.id %}">
                                    <i class="fa fa-edit" aria-hidden="true"></i>
                                </a>
                                {#                            {%endif%}#}
                                {#                            {% if request|has_permission:"customer_edit" %}#}
                                <a style="color:#d9534f;" href="{% memory_url request 'rbac:second_menu_del' pk=row.id %}">
                                    <i class="fa fa-trash-o"></i>
                                </a>
                                {#                            {% endif %}#}
                            </td>
                            {#                     {% endif %}#}
                        </tr>
                        <tr  class="{% if row.id|safe == second_menu_id %}active{% endif %}">
                            <td colspan="2" style="border-top: 0">{{ row.url }}</td>
                        </tr>
                    {% endfor %}

                    </tbody>
                </table>
            </div>
        </div>
        <!-- 权限列表 panel-->
        <div class="col-md-5">
            <!--table panel  -->
            <div class="panel panel-default">
                <div class="panel-heading">
                    <i class="fa fa-gavel" aria-hidden="true"></i> 权限
                    <div class="btn-group right">
                        {% if second_menu_id %}
                            <a href="{% memory_url request 'rbac:permission_add' second_menu_id %}" class="right btn btn-success btn-xs"
                               style="padding: 2px 8px;margin: -3px;">
                                <i class="fa fa-plus-circle" aria-hidden="true"></i>
                                新建
                            </a>
                            <a href="{% memory_url request 'rbac:multi_permissions' %}" class="btn btn-xs btn-primary"
                                style="padding: 2px 8px;margin: -3px;">
                                <i class="fa fa-mail-forward" aria-hidden="true"></i>
                                批量操作
                            </a>
                        {% endif %}

                    </div>
                </div>
                <table class="table">
                    <thead>
                        <tr>
                            <th>名称</th>
                            <th>CODE&URL</th>
                            <th>选项</th>
                        </tr>
                    </thead>
                    <tbody>
                    {% for row in permissions %}
                        <tr>
                            <td rowspan="2">{{ row.title }}</td>
                            <td>{{ row.name }}</td>
                            {#                     {% if request|has_permission:"customer_edit" or request|has_permission:"customer_del" %}#}
                            <td>
                                {#                            {% if request|has_permission:"customer_edit" %}#}
                                <a style="color:#333333;" href="{% memory_url request 'rbac:permission_edit' pk=row.id %}">
                                    <i class="fa fa-edit" aria-hidden="true"></i>
                                </a>
                                {#                            {%endif%}#}
                                {#                            {% if request|has_permission:"customer_edit" %}#}
                                <a style="color:#d9534f;" href="{% memory_url request 'rbac:permission_del' pk=row.id %}">
                                    <i class="fa fa-trash-o"></i>
                                </a>
                                {#                            {% endif %}#}
                            </td>
                            {#                     {% endif %}#}
                        </tr>
                        <tr>
                            <td colspan="2" style="border-top: 0">{{ row.url }}</td>
                        </tr>
                    {% endfor %}

                    </tbody>
                </table>
            </div>
        </div>
    </div>
{% endblock %}